﻿///<reference path="../../../Scripts/jquery-1.4.1-vsdoc.js"/>
///<reference path="../utils/Utils.js"/>

function BibleChapter(key, title) {

    this.Xml;
    this.Key = key;
    this.Title = title;
    this.Verses = [];

    this.Search = function (searchPattern) {
        var results = [];
        for (var i = 0; i < this.Verses.length; i++) {
            var verse = this.Verses[i];
            if (verse.CorrespondToSerachPattern(searchPattern))
                results.push(verse);
        }
        return results;
    }

    this.AddVerse = function (key, title, xml) {
        return this.GetVerseByIndex(this.Verses.push(new BibleVerse(key, title, xml)) - 1);
    }

    this.GetVerseByIndex = function (index) {
        return this.Verses[index];
    }

    this.GetVerse = function (verseKey) {
        var verseIndex = appPointer.KeyManager.GetVerseIndexFromKey(verseKey);
        return this.GetVerseByIndex(verseIndex);
    }

    this.GetKey = function () {
        return this.Key;
    }

}